package com.jstyle.jclife.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.jstyle.jclife.R;
import com.jstyle.jclife.adapter.RecyclerViewBaseAdapter;
import com.jstyle.jclife.adapter.SupportAdapter;
import com.jstyle.jclife.utils.ScreenUtils;

import java.util.Arrays;

import butterknife.BindArray;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class GetSupportActivity extends BaseActivity implements RecyclerViewBaseAdapter.OnItemClickListener {

    @BindView(R.id.bt_goal_back)
    Button btGoalBack;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_share)
    ImageView ivShare;
    @BindView(R.id.RecyclerView_supprot)
    RecyclerView RecyclerViewSupprot;
    @BindArray(R.array.support_array)
    String[]supportArray;
    private String PrivcyUrl="https://getfomofit.com/support";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_get_support);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        btGoalBack.setText(R.string.Get_Support);
        ScreenUtils.setTitleTypeface(btGoalBack);
        ivShare.setVisibility(View.GONE);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        SupportAdapter aboutAdapter = new SupportAdapter(Arrays.asList(supportArray));
        aboutAdapter.setOnItemClickListener(this);
        RecyclerViewSupprot.setAdapter(aboutAdapter);
        RecyclerViewSupprot.addItemDecoration(dividerItemDecoration);
        RecyclerViewSupprot.setLayoutManager(linearLayoutManager);
    }

    @OnClick(R.id.bt_goal_back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void onItemClick(int position) {
        switch (position){
            case 1:
                dailPhone();
                break;
            case 2:
                startActivity(FeedBackActivity.class);
                break;
        }
    }

    private void dailPhone() {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        Uri content_url = Uri.parse(PrivcyUrl);
        intent.setData(content_url);
        startActivity(intent);
    }
}
